﻿<div class="row clearfix" [@routerTransition]>
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card main-content">
            <div class="header">
                <h2>
                    {{l('Users')}}
                </h2>
                <ul class="header-dropdown m-r--5">
                    <i class="fa fa-spin fa-spinner" *ngIf="isTableLoading"></i>
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="javascript:void(0);" class=" waves-effect waves-block()" (click)="refresh();"><i class="material-icons">refresh</i> {{l('Refresh')}}</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">

            <!-- ******************************************************** -->
                <table class="table table-hover table-striped">
                    <thead>
                        <tr>
                            <th>{{l('UserName')}}</th>
                            <th>{{l('FullName')}}</th>
                            <th>{{l('EmailAddress')}}</th>
                            <th>
                                <div style="text-align:center">{{l('IsActive')}}</div>
                            </th>
                            <th>{{l('Actions')}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let user of users | paginate: { id: 'server', itemsPerPage: pageSize, currentPage: pageNumber, totalItems: totalItems }">
                            <td>{{user.userName}}</td>
                            <td>{{user.fullName}}</td>
                            <td>{{user.emailAddress}}</td>
                            <td align="center">
                                <i class="material-icons" *ngIf="user.isActive" style="color:green;">check_box</i>
                                <i class="material-icons" *ngIf="!user.isActive" style="color:red;">indeterminate_check_box</i>
                            </td>
                            <td class="dropdown">
                                <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                    <i class="material-icons">menu</i>
                                </a>
                                <ul class="dropdown-menu pull-right">
                                    <li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="editUser(user)"><i class="material-icons">create</i>{{l('Edit')}}</a></li>
                                    <li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="delete(user)"><i class="material-icons">delete_sweep</i>{{l('Delete')}}</a></li>
                                </ul>
                            </td>
                        </tr>
                    </tbody>
                </table>
            <!-- ******************************************************** -->

                <div class="text-align: center;" *ngIf="totalItems > pageSize">
                    <pagination-controls (pageChange)="getDataPage($event)" id="server"></pagination-controls>
                </div>
                <button type="button" data-toggle="modal" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" (click)="createUser()">
                    <i class="material-icons">add</i>
                </button>
            </div>
        </div>
    </div>
</div>

<create-user-modal #createUserModal (modalSave)="refresh()"></create-user-modal>
<edit-user-modal #editUserModal (modalSave)="refresh()"></edit-user-modal>